from selenium import webdriver
import time
import re

from bs4 import BeautifulSoup
findtime = re.compile(r'<span class="card-title-wrapper">(.*)</span>')
findimage = re.compile(r'<img src="(.*)" class="card-image-content">')

def openurl(url):
    browser = webdriver.Chrome()  # 打开浏览器
    browser.get(url)  # 进入相关网站

    datalist=[]
    html = browser.page_source
    count=0
    while (browser.find_element_by_css_selector(".load-more") != None):
        # time.sleep(1)
        # print(count)
        count+=1
        if count==15:
            break
        browser.find_element_by_css_selector(".load-more").click()

    html = browser.page_source  # 获取网站源码
    soup = BeautifulSoup(html, "html.parser")
    for item in soup.find_all('p', class_="card-title"):  # 查找符合要求的字符串，形成列表
        # print(item)   #测试：查看电影item全部信息
        item = str(item)
        link = re.findall(findtime, item)[0]

        print(link)

    for item in soup.find_all('p', class_="card-image"):  # 查找符合要求的字符串，形成列表
        # print(item)   #测试：查看电影item全部信息
        item = str(item)
        link2 = re.findall(findimage, item)[0]
        print(link2)

    print("爬取完毕！！")

    return datalist





url = 'https://m.jianbihua.com/phototag/73099'
dict = openurl(url)